// API相关类型定义
import { Dataset } from './dataset'
import { ImageData, ImageMetadata } from './image'
import { Task, TaskResult, TaskParams, TaskStatus, TaskStatusInfo } from './task'

// API响应基础接口
export interface ApiResponse<T = unknown> {
    success: boolean
    data?: T
    message?: string
    error?: string
    timestamp: string
}

// API错误接口
export interface ApiError {
    code: string
    message: string
    details?: Record<string, unknown>
    timestamp: string
}

// 分页响应接口
export interface PaginatedResponse<T> {
    items: T[]
    total: number
    page: number
    pageSize: number
    hasNext: boolean
    hasPrev: boolean
}

// API客户端接口
export interface ApiClient {
    // 数据集相关
    getDatasets(): Promise<Dataset[]>
    getDataset(id: string): Promise<Dataset>

    // 影像数据相关
    getImageData(imageId: string): Promise<ImageData>
    getImageMetadata(imageId: string): Promise<ImageMetadata>

    // 任务相关
    getTasks(datasetId: string): Promise<Task[]>
    startTask(taskId: string, params: TaskParams): Promise<TaskResult>
    getTaskStatus(taskId: string): Promise<TaskStatusInfo>
    getTaskResults(taskId: string): Promise<TaskResult[]>
}

// HTTP方法类型
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'

// 请求配置接口
export interface RequestConfig {
    method: HttpMethod
    url: string
    data?: unknown
    params?: Record<string, unknown>
    headers?: Record<string, string>
    timeout?: number
}

// API端点配置
export interface ApiEndpoints {
    DATASETS: string
    DATASET: (id: string) => string
    IMAGE_DATA: (id: string) => string
    IMAGE_METADATA: (id: string) => string
    TASKS: (datasetId: string) => string
    START_TASK: string
    TASK_STATUS: (id: string) => string
    TASK_RESULTS: (id: string) => string
}